<?php

namespace Database\Factories;

use App\Models\Qnr;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use Overtrue\Pinyin\Pinyin;

/**
 * @extends \Illuminate\Database\Eloquent\Factories\Factory<\App\Models\Qnr>
 */
class QnrFactory extends Factory
{

    /**
     * 工厂对应的模型名称。
     *
     * @var string
     */
    protected $model = Qnr::class;

    /**
     * Define the model's default state.
     *
     * @return array<string, mixed>
     */
    public function definition()
    : array
    {

        $title = $this->faker->sentence;

        $options = [
            [
                'key'   => $this->faker->sentence, // 问题内容

                // 选择
                'value' => [
                    "A" => $this->faker->sentence,
                    "B" => $this->faker->sentence,
                    "C" => $this->faker->sentence,
                    "D" => $this->faker->sentence,
                ],

                // 答案
                'desc'  => "A", //答案
            ],
            [
                'key'   => $this->faker->sentence, // 问题内容

                // 选择
                'value' => [
                    "A" => $this->faker->sentence,
                    "B" => $this->faker->sentence,
                    "C" => $this->faker->sentence,
                    "D" => $this->faker->sentence,
                ],

                // 答案
                'desc'  => "A", //答案
            ],
            [
                'key'   => $this->faker->sentence, // 问题内容

                // 选择
                'value' => [
                    "A" => $this->faker->sentence,
                    "B" => $this->faker->sentence,
                    "C" => $this->faker->sentence,
                    "D" => $this->faker->sentence,
                ],

                // 答案
                'desc'  => "A", //答案
            ],
            [
                'key'   => $this->faker->sentence, // 问题内容

                // 选择
                'value' => [
                    "A" => $this->faker->sentence,
                    "B" => $this->faker->sentence,
                    "C" => $this->faker->sentence,
                    "D" => $this->faker->sentence,
                ],

                // 答案
                'desc'  => "A", //答案
            ],
            [
                'key'   => $this->faker->sentence, // 问题内容

                // 选择
                'value' => [
                    "A" => $this->faker->sentence,
                    "B" => $this->faker->sentence,
                    "C" => $this->faker->sentence,
                    "D" => $this->faker->sentence,
                ],

                // 答案
                'desc'  => "A", //答案
            ],
        ];

        return [
            'qnr_id'       => Str::uuid(),
            'admin_id'     => 1,
            'c_key'        => 1,
            'title'        => $title,
            'slug'         => Pinyin::permalink($title),
            'content'      => $this->faker->paragraphs(13,true),
            'introduction' => $this->faker->paragraphs(4,true),
            'tel_phone'    => $this->faker->phoneNumber,
            'sponsor'      => $this->faker->company,
            'options'      => json_encode($options),
        ];
    }
}
